<template>
  <div class="left-menu">
    <div class="logo">
      <img src="@/assets/images/logo.gif" alt="" />
      <span>后台管理系统</span>
    </div>
    <!--       @open="handleOpen"
      @close="handleClose" -->
    <el-menu
      unique-opened
      router
      :default-active="$route.path"
      class="el-menu-vertical-demo"
      background-color="#304156"
      text-color="#fff"
    >
      <template v-for="item in menus">
        <!-- 没儿子的菜单 -->
        <el-menu-item
          :index="item.meta.path"
          v-if="item.children.length === 1"
          :key="item.meta.path"
        >
          <i class="iconfont icon-home"></i>
          <span slot="title">{{ item.meta.title }}</span>
        </el-menu-item>
        <!-- 有儿子的菜单 -->
        <el-submenu :index="item.meta.path" v-else :key="item.meta.title">
          <template slot="title">
            <i class="iconfont icon-total"></i>
            <span>{{ item.meta.title }}</span>
          </template>
          <el-menu-item
            v-for="subItem in item.children"
            :key="subItem.meta.path"
            :index="subItem.meta.path"
            >{{ subItem.meta.title }}</el-menu-item
          >
        </el-submenu>
      </template>

      <!-- 后台首页 -->
      <!-- <el-menu-item index="/home">
        <i class="iconfont icon-home"></i>
        <span slot="title">后台首页</span>
      </el-menu-item> -->
      <!-- 订单管理 -->
      <!-- <el-menu-item index="/order">
        <i class="iconfont icon-order"></i>
        <span slot="title">订单管理</span>
      </el-menu-item> -->
      <!-- 商品管理 -->
      <!-- <el-submenu index="1">
        <template slot="title">
          <i class="iconfont icon-goods"></i>
          <span>商品管理</span>
        </template>
        <el-menu-item index="/goods/goods-list">商品列表</el-menu-item>
        <el-menu-item index="/goods/goods-add">商品添加</el-menu-item>
        <el-menu-item index="/goods/goods-cate">商品分类</el-menu-item>
      </el-submenu> -->
      <!-- 店铺管理 -->
      <!-- <el-menu-item index="/shop">
        <i class="iconfont icon-shop"></i>
        <span slot="title">店铺管理</span>
      </el-menu-item> -->
      <!-- 账号管理 -->
      <!-- <el-submenu index="2">
        <template slot="title">
          <i class="iconfont icon-account"></i>
          <span>账号管理</span>
        </template>
        <el-menu-item index="/account/account-list">账号列表</el-menu-item>
        <el-menu-item index="/account/account-add">账号添加</el-menu-item>
        <el-menu-item index="/account/password-modify">修改密码</el-menu-item>
        <el-menu-item index="/account/person">个人中心</el-menu-item>
      </el-submenu> -->
      <!-- 销售统计 -->
      <!-- <el-submenu index="3">
        <template slot="title">
          <i class="iconfont icon-total"></i>
          <span>销售统计</span>
        </template>
        <el-menu-item index="/total/total-goods">商品统计</el-menu-item>
        <el-menu-item index="/total/total-order">订单统计</el-menu-item>
      </el-submenu> -->
    </el-menu>
  </div>
</template>

<script>
import local from "@/utils/local";
export default {
  data() {
    return {
      menus: [], //菜单
    };
  },
  methods: {},
  created() {
    this.menus = local.get("menus");
  },
};
</script>

<style lang="scss" scoped>
.el-menu {
  border-right: 0;
}
.left-menu {
  background-color: #304156;
}
.logo {
  display: flex;
  height: 60px;
  align-items: center;
  color: white;
  font-weight: 500;
  justify-content: space-around;
  img {
    width: 55px;
  }
}
.iconfont {
  margin-right: 5px;
}
.el-submenu {
  ::v-deep .el-menu--inline {
    .el-menu-item {
      background: darken(#304156, 5%) !important;
      &:hover {
        background: darken(#304156, 10%) !important;
      }
    }
  }
}
</style>